import Vue from 'vue'
import uniCrazyRouter from "@/node_modules/uni-crazy-router/dist/index.js"
Vue.use(uniCrazyRouter)

// 拦截登录
// import bindInterceptLogin from '@/router/interceptLogin/interceptLogin'
// const interceptLogin = bindInterceptLogin()

// 拦截tabbar切换
import bindInterceptTabBar from '@/router/interceptTabBar/interceptTabBar'
const interceptTabBar = bindInterceptTabBar()

// 路由前置守卫
uniCrazyRouter.beforeEach(async (to, from, next) => {
	// 逻辑代码
	console.log('进入路由前置守卫');

	next()
})

// 路由后置守卫
uniCrazyRouter.afterEach((to, from) => {
	// 逻辑代码
	console.log('进入路由后置守卫，路由后置守卫可以监听开屏页面、页面刷新');
})

// 页面错误处理
uniCrazyRouter['on' + 'Error']((to, from) => {
	uni.showToast({
		title:'错误路由',
		icon:'none'
	})
	// console.log(to);
	// 跳转到'陌生'路由会监听跳转到404页面
	// uni.navigateTo({
	// 	url: '/pages/errorPages/404'
	// })

})
